package lab02.test19;

/**
 * Created by lenovo on 2017/10/31.
 */
public class Test {
    public static void main(String[] args) {
        //19、 实现字符串的大小写转换并倒序输出
        // 如输入为“HelloWord”，输出为“DROwOLLEH”。
        String results = "HelloWord";
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < results.length(); i++) {
            char tmp = results.charAt(i);
            if (tmp >= 'a' && tmp <= 'z') {
                tmp = (char) (tmp - 32);
                stringBuffer.append(tmp);
            } else if (tmp >= 'A' && tmp <= 'Z') {
                tmp = (char) (tmp + 32);
                stringBuffer.append(tmp);
            }
        }
        //返回StringBuffer对象的颠倒顺序。
        System.out.println(stringBuffer.reverse());
    }
}
